/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Lenovo
 * Date: 2025-08-15
 * Time: 21:25
 */
//https://leetcode.cn/problems/he-wei-sde-liang-ge-shu-zi-lcof/
public class Test {
    public static int[] twoSum(int[] arr, int target) {
        int[] brr=new int[2];
        int i=0;
        int j=arr.length-1;
        while(i<j){
            if(arr[i]+arr[j]<target){
                i++;
            }
            else if(arr[i]+arr[j]>target){
                j--;
            }
            else{
                brr[0]=arr[i];
                brr[1]=arr[j];
                return brr;
            }
        }
        return null;
    }
    public static void main(String[] args) {
        int[] arr={8, 21, 27, 34, 52, 66};
        int[] brr=twoSum(arr,61);
        System.out.println(brr[0]+" "+brr[1]);
    }
}
